Repository navigation
sleep: respect the order of feedback when mining outcomes - #481
Open
Vidwaan Singhania (Vidwaansinghania) wants to merge 3 commits into
Open
Vidwaan Singhania (Vidwaansinghania) wants to merge 3 commits into
Vidwaan Singhania (Vidwaansinghania) wants to merge 3 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Follow-up to #457, which left this open for discussion.
heuristic_mine's docstring says a task isfailwhen "negative feedback present and no later positive". The code ignored order: any negative signal anywhere in the session gavefail. So a common, successful session was mined as a failure:failsuccessfailfailfailfailfailfailOnly the first row changes. A task mined as
failgoes into replay and the held-out gate as a failure, so a corrected-then-approved session was teaching the optimizer the wrong lesson.How
SessionDigest.feedback_by_turn(new,List[List[str]], default[]): the same signals asfeedback_signals, grouped by user turn in transcript order. Digests persisted before this field existed still load (the handoff reader in__main__.pyalready filters to known fields) and get[].digest_transcript) fills it: each user turn's_detect_feedbackresult goes into bothfeedback_signals(unchanged) andfeedback_by_turn.heuristic_minegets one new branch,_approved_after_last_negative: if a user turn after the last negative turn carries a positive signal, the outcome issuccess. A turn with both ("thanks, but still broken") counts as negative.feedback_signalsis exactly the per-turn lists joined together. Harvesters that add signals of their own (neg:tool_error,neg:cursor_turn_error,neg:opencode_message_error) or de-duplicate them can't say where those fall, so they keep today's unordered rule. Every other harvester is therefore unchanged by this PR.No change to the
neg:/pos:format, the LLM miner, ordedup_tasks.Tests
tests/test_sleep_feedback_order.py(stdlibunittest, no network, 11 tests): negative then approval issuccess; approval then negative, both in the last turn, and negative/approval/negative are allfail; negative-only and positive-only are unchanged; the fallback with no per-turn data, with a signal outside any turn, and with a persisted digest that lacks the field; and two end-to-end checks throughdigest_transcripton a synthetic Claude Code transcript.main, 10 of the 11 fail (most because the field doesn't exist yet) and all pass here.test_sleep_config_encoding,test_sleep_staging_fanout,test_sleep_engine::test_cycle_stages_only_documents_that_changed,test_harvest_project_scope,test_reproducibility,test_openai_compatible_config,test_minimax_config,test_benchmark_task_output_paths). They look Windows-specific and are unrelated.Not in this PR
feedback_by_turntoo. Their extra error signals would need a turn position first, so I've left them on the old rule. Happy to do them in a follow-up if you want this everywhere.success, which covers the most common case. An opener with a negative phrase and no later approval is stillfail.